#ifndef _AI_TOWN_DATA_CACHE_INC
#define _AI_TOWN_DATA_CACHE_INC

#pragma warning( disable: 4786 )

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class t_creature_array;

#include <list>
#include <map>

#include "adventure_object_ptr.h"

class t_town;

class t_ai_town_data_cache
{
public:
	struct t_threat_element
	{
		t_adventure_object_ptr	object;
		int						movement;
	};

	typedef std::map< t_creature_array*, t_threat_element > t_threat_map;
	typedef std::list< t_creature_array* > t_threat_list;

	t_ai_town_data_cache();

	t_threat_map const&	get_threat_map() const;
	void				get_threat_list( t_threat_list& list, t_threat_list* invalidated ) const;
	float				get_value_drop() const;
	void				inc_threat( t_town* town, t_creature_array* army );
	bool				is_threatened() const;
	void				set_value_drop( float value_drop );
	void				start_turn();

protected:
	t_threat_map			m_threat_map;
	float					m_value_drop;
};

inline t_ai_town_data_cache::t_ai_town_data_cache() : m_value_drop(0.0f)
{
}

inline float t_ai_town_data_cache::get_value_drop() const
{
	return m_value_drop;
}

inline void t_ai_town_data_cache::start_turn()
{
	m_threat_map.clear();
}

inline const t_ai_town_data_cache::t_threat_map& t_ai_town_data_cache::get_threat_map() const
{
	return m_threat_map;
}

inline bool t_ai_town_data_cache::is_threatened() const
{
	return !m_threat_map.empty();
}

inline void t_ai_town_data_cache::set_value_drop( float value_drop ) 
{
	m_value_drop = value_drop;
}

#endif
